package com.platform.module.common.redis.lock;

import com.platform.module.common.base.CommonResp;

import java.util.function.Supplier;

public interface DistributedLock {
    long TIMEOUT_MILLIS = 30000L;

    int RETRY_TIMES = 2147483647;

    long SLEEP_MILLIS = 500L;

    String LOCK_PREFIX = "LOCK";

    boolean lock(String key);

    boolean lock(String key, Runnable runnable);

    boolean lock(String key, int retryTimes);

    boolean lock(String key, int retryTimes, long sleepMillis);

    boolean lock(String key, long expire);

    boolean lock(String key, long expire, int retryTimes);

    boolean lock(String key, long expire, int retryTimes, long sleepMillis);

    boolean releaseLock(String key);

    boolean lock(String key, String uuid, long expire, int retryTimes);

    boolean lock(String key, String uuid, long expire, int retryTimes, long sleepMillis);

    boolean releaseLock(String key, String uuid);

    <T> CommonResp<T> lock(String key, long expire, int retryTimes, long sleepMillis, Supplier<CommonResp<T>> supplier);


}
